# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import shutil
from cerbero.utils import to_unixpath

class Recipe(recipe.Recipe):
    name = 'gst-transcoder'
    version = '1.9'
    licenses = [License.LGPLv2Plus]
    remotes = {'origin': 'https://github.com/pitivi/gst-transcoder.git'}
    commit = 'origin/master'
    deps = ['gstreamer-1.0', 'gst-plugins-base-1.0']

    files_libs = ['libgsttranscoder-1.0']

    files_typelibs = [
        'GstTranscoder-1.0'
    ]

    files_plugins_devel = [
        'include/gstreamer-1.0/gst/transcoder/',
    ]

    files_plugins_encoding = [
             'lib/gstreamer-1.0/libgsttranscoderplugin%(mext)s',
    ]

    files_plugins_encoding_devel = [
             'lib/gstreamer-1.0/libgsttranscoderplugin.a', 'lib/gstreamer-1.0/libgsttranscoderplugin.la',
    ]

    files_bins = ['gst-transcoder-1.0']
    btype = BuildType.MAKEFILE

    config_sh = './configure'
    configure_tpl = "%(config-sh)s --prefix %(prefix)s %(options)s"

    def prepare(self):
        # --libdir is relative in meson
        libdir = self.config.libdir.replace(
            os.path.join(os.path.commonprefix([
            to_unixpath(self.config.prefix),
            to_unixpath(self.config.libdir)]), ''), '')

        self.configure_options = ' --libdir=%s/ ' % libdir
